package com.lottery.service.pc28;

import com.lottery.dto.MessageTube;
import com.lottery.dto.SscOddsShow;
import com.lottery.obtainData.SscYesWinningFactory.InitUtils;
import com.lottery.utils.messageTube.MessageFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
/**
 * 初始化数据字典
 */
public class InitData {
    @Resource
    private MessageFactory messageFactory;

    @Autowired
    private InitUtils initUtils;

    @Autowired
    private JedisClient jedis;
    //初始化斗牛map集合
    public static Map<Integer, String> niuNiuMap = new HashMap<>();

    //初始化赔率查询map
    public static Map<String, String> translateMap = new HashMap<>();
    public static Map<String, String> pc28TranslateMap = new HashMap<>();


    //初始化玩法集合
    public static List<String> translateList = new ArrayList<>();
    public static  List<String> pc28TranslateList = new ArrayList<>();

    //ssc赔率集合
    public static Map<String, List<SscOddsShow>> sscOddMap = new HashMap<>();
    //pc28赔率集合
    public static  Map<String, List<SscOddsShow>> pc28OddMap = new HashMap<>();


    public static List<String> oddDecorateList = new ArrayList<>();

    public static Map<String,Map<String,MessageTube>> MESSAGE_GROUP  = new HashMap<>();



    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    /*@PostConstruct*/
    public void init() {
        niuNiuMap.put(1, "牛一");
        niuNiuMap.put(2, "牛二");
        niuNiuMap.put(3, "牛三");
        niuNiuMap.put(4, "牛四");
        niuNiuMap.put(5, "牛五");
        niuNiuMap.put(6, "牛六");
        niuNiuMap.put(7, "牛七");
        niuNiuMap.put(8, "牛八");
        niuNiuMap.put(9, "牛九");
        niuNiuMap.put(0, "牛牛");
        niuNiuMap.put(-1, "无牛");

        //ssc转译
        translateMap.put("大小单双玩法", "ssc_bigSmallPayRule");
        translateMap.put("数字定位玩法", "ssc_numberPosPayRule");
        translateMap.put("数字玩法", "ssc_numberPayRule");
        translateMap.put("数字组合玩法", "ssc_numberComPayRule");
        translateMap.put("斗牛玩法", "ssc_bullFighting");
        translateMap.put("趣味玩法", "ssc_funnyPayRule");
        //pc28转译
        pc28TranslateMap.put("大小单双玩法","pc_bigSmallPayRule");
        pc28TranslateMap.put("单点","pc_singlePointPayRule");
        pc28TranslateMap.put("极大极小","pc_maxminPayRule");
        pc28TranslateMap.put("豹顺对","pc_assotedPayRule");



        //ssc初始化数据
        translateList.add("ssc_bigSmallPayRule");//大小单双玩法
        translateList.add("ssc_numberPosPayRule");//定位玩法
        translateList.add("ssc_numberPayRule");//数字玩法
        translateList.add("ssc_numberComPayRule");//数字组合玩法
        translateList.add("ssc_bullFighting");//斗牛玩法
        translateList.add("ssc_funnyPayRule");//趣味玩法

        //pc28初始化数据
        pc28TranslateList.add("pc_bigSmallPayRule");//大小单双玩法
        pc28TranslateList.add("pc_singlePointPayRule");//单点玩法
        pc28TranslateList.add("pc_maxminPayRule");//猜数字玩法(极大,极小)
        pc28TranslateList.add("pc_assotedPayRule");//猜数字玩法(豹顺对)


        oddDecorateList.add("前");
        oddDecorateList.add("中");
        oddDecorateList.add("后");


        //项目启动初始化信息通道
        messageFactory.InitMessagetube();
    }




//    //创建定时任务运行体系
//    public class ListenRedisMethod extends TimerTask {
//        @Override
//        public void run() {
//            logger.debug("listenSscOddChange timer start");
//            if (jedis.get("sscOddChange").equals("1")) {
//                initUtils.getSscOddsMap(1);
//            }
//            logger.debug("listenSscOddChange timer end");
//        }
//    }
//
//    //定时监听redis状态(没半个小时监听一次)
//    public void listenSscOddChange() {
//        logger.debug("listenSscOddChange start");
//        try {
//            ListenRedisMethod ss = new ListenRedisMethod();
//            SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd HH:mm:ss");
//            String dateString = "2018-3-14 15:11:00";
//            Date date = null;
//            date = sdf.parse(dateString);
//            timer.schedule(ss, date, 1000 * 60 * 30);
//            //timer.schedule(ss,date,1000*10);
//        } catch (ParseException e) {
//            logger.debug("listenSscOddChange e,{}", e);
//            e.printStackTrace();
//        }
//        logger.debug("listenSscOddChange start");
//    }


}
